from django.db import models
from com.kjssoft.common.globals import DBTableAssist

__author__ = 'Sea'

class RainbowPhotoFrameLabelManager(models.Manager):
    def create(self, keyword, **kwargs):
        labels = self.filter(keyword = keyword)
        if labels.count():
            label = labels[0]
        else:
            label = super(RainbowPhotoFrameLabelManager, self).create(keyword = keyword).save()
        return label


class RainbowPhotoFrameLabel(models.Model):
    keyword     = models.CharField(max_length=500, unique=True)

    def __unicode__(self):
        return 'rainbow photo frame label %s' % self.keyword

    class Meta:
        db_table = DBTableAssist.get_db_table_name('rainbow_photo_frame_label')
